package com.poisonh.unifiedauth.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.poisonh.unifiedauth.R;
import com.poisonh.unifiedauth.utils.ConstantUitls;
import com.poisonh.unifiedauth.widget.CircleImageView;
import com.zhy.autolayout.AutoRelativeLayout;

/**
 * 等级提升
 * Created by PoisonH on 2016/6/28.
 */
public class SettingUpLevelActivity extends BaseActivity implements View.OnClickListener
{
    private CircleImageView mCivUpLevelHead;
    private TextView mTvUpLevelPhone;
    private AutoRelativeLayout mArlUpLevelBindEmail;
    private AutoRelativeLayout mArlUpLevelBindInfo;
    private AutoRelativeLayout mArlUpLevelEdu;

    @Override
    protected void loadContentView(Bundle savedInstanceState)
    {
        setContentView(R.layout.activity_settinguplevel);
        initTitleView();
        initView();
    }

    @Override
    protected void initView()
    {
        mRightBtn.setVisibility(View.GONE);
        setTitleTxt("等级提升");

        mCivUpLevelHead = (CircleImageView) findViewById(R.id.civ_uplevel_head);
        mTvUpLevelPhone = (TextView) findViewById(R.id.tv_uplevel_phone);
        mArlUpLevelBindEmail = (AutoRelativeLayout) findViewById(R.id.arl_uplevel_bindemail);
        mArlUpLevelBindInfo = (AutoRelativeLayout) findViewById(R.id.arl_uplevel_bindinfo);
        mArlUpLevelEdu = (AutoRelativeLayout) findViewById(R.id.arl_uplevel_edu);

        mArlUpLevelBindEmail.setOnClickListener(this);
        mArlUpLevelBindInfo.setOnClickListener(this);
        mArlUpLevelEdu.setOnClickListener(this);
        mLeftBtn.setOnClickListener(this);

        initShow();
    }

    /**
     * 初始化显示内容
     */
    private void initShow()
    {
        if (mStrUserHeadUrl != null)
        {
            Glide.with(this).load(mStrUserHeadUrl).into(mCivUpLevelHead);
        }
        if (mStrUserName != null)
        {
            mTvUpLevelPhone.setText(mStrUserName);
        } else if (mStrUserPhone != null)
        {
            mTvUpLevelPhone.setText("+86  " + mStrUserPhone);
        }
    }

    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
            case R.id.arl_uplevel_bindemail:
                if (mStrUserEmail != null)
                {
                    super.jumpActivity(SettingUpLevelActivity.this, ChangeEmailActivity.class);
                } else
                {
                    super.jumpActivity(SettingUpLevelActivity.this, InputEmailActivity.class);
                }
                break;
            case R.id.arl_uplevel_bindinfo:
                if (mStrUserReallyName == null || mStrUserReallyName.equals("null") || mStrUserReallyName.length() <= 0)
                {
                    super.jumpActivity(SettingUpLevelActivity.this, SettingBindInfoActivity.class);
                } else
                {
                    Intent mIntent = new Intent(SettingUpLevelActivity.this, SettingPerfectActivity.class);
                    Bundle mBundle = new Bundle();
                    mBundle.putString("REALLYNAME", mStrUserReallyName);
                    mBundle.putString("CARD", mStrUserCard);
                    mBundle.putString("HEADURL", mStrUserHeadUrl);
                    mIntent.putExtras(mBundle);
                    startActivity(mIntent);
                }
                break;
            case R.id.arl_uplevel_edu:
                super.jumpActivity(SettingUpLevelActivity.this, SettingScoreActivity.class);
                break;
            case R.id.ib_left_btn:
                finish();
                break;
        }
    }

}
